//
// Created by 86136 on 2024/11/14.
//
// Line.cpp
#include "Line.h"
class OutLine::Line
{
public:
    Line(int x1, int y1, int x2, int y2)
            : _p1(x1, y1)
            , _p2(x2, y2)
    {}
    void showLine()
    {
        std::cout << "Line:" << std::endl;
        _p1.showPoint();
        _p2.showPoint();
    }
private:
    // 嵌套类放入private，专门为line服务
    class Point
    {
    public:
        ~Point() = default;
        Point(int a, int b)
                : _x(a)
                , _y(b)
        {}
        void showPoint() const
        {
            std::cout << "\tPoint: " <<  _x << " " << _y << std::endl;
        }
    private:
        int _x, _y;

    };
    Point _p1, _p2;
};

OutLine::OutLine(int x1, int y1, int x2, int y2)
: _Lineptr(new Line(x1, y1, x2, y2))
{
    std::cout << "create outLine" << std::endl;
}

OutLine::~OutLine()
{
    std::cout << "delete outLine" << std::endl;
    delete _Lineptr;
    _Lineptr = nullptr;
}

void OutLine::showOutLine() {
    if (_Lineptr) {
        _Lineptr->showLine();
    }
}